# Start with fully-featured Node.js base image
FROM node:14.4.0 AS build

WORKDIR /home/node/app

# Copy dependency information and install all dependencies
COPY package.json yarn.lock ./

RUN yarn install --frozen-lockfile

# Copy source code (and all other relevant files)
COPY src ./src

# Build code
COPY tsconfig.json ./
RUN yarn build

# Run-time stage
FROM node:14.4.0-alpine

# Expose port 9000
EXPOSE 1234

WORKDIR /home/node/app

# Copy dependency information and install production-only dependencies
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production

# Copy results from previous stage
COPY --from=build /home/node/app/build ./

CMD [ "node", "index.js" ]
